
import { Base } from '../utils/base.js';

class Order extends Base {
    constructor() {
        super();
    }

    /**
     * 获取产品订单列表
     */
    getProductOrderList(callBack) {
        var params = {
            url: 'product-order',
            sCallBack: function (res) {
                callBack && callBack(res);
            }
        }
        this.request(params);
    }

    /**
     * 获取产品订单详情
     */
    getProductOrderInfo(id,callBack) {
        var params = {
            url: `product-order/${id}`,
            sCallBack: function (res) {
                callBack && callBack(res);
            }
        }
        this.request(params);
    }

  /**
   * 获取核销订单详情
   */
  getOrderInfo(data, callBack) {
    var params = {
      url: 'order',
      data: data,
      sCallBack: function (res) {
        callBack && callBack(true,res);
      },
      eCallBack: function (res) {
        callBack && callBack(false, res);
      },
    }
    this.request(params);
  }

  /**
   *  订单核销
   */
  setOrder(data, callBack) {
    var params = {
      url: 'order',
      type: 'PUT',
      data: data,
      sCallBack: function (res) {
        callBack && callBack(true, res);
      },
      eCallBack: function (res) {
        callBack && callBack(false, res);
      },
    }
    this.request(params);
  }
    /**
     * 创建产品订单
     */
    createProductOrder(data,callBack) {
        var params = {
            url: 'product-order',
            type: 'POST',
            data: data,
            sCallBack: function (res) {
                callBack && callBack(true, res);
            },
            eCallBack: function (res) {
              callBack && callBack(false, res);
            },
        }
        this.request(params);
    }

    /**
     * 删除订单
     */
    deleteProductOrder(data,callBack) {
      var params = {
          url: 'product-order',
          type: 'DELETE',
          data: data,
          sCallBack: function (res) {
              callBack && callBack(true, res);
          },
          eCallBack: function (res) {
            callBack && callBack(false, res);
          },
      }
      this.request(params);
  }

    /**
   * 支付公用
   */
  preOrder(data, callBack) {
    var params = {
      url: 'pay/pre_order',
      type: 'POST',
      data: data,
      sCallBack: function (res) {
        callBack && callBack(true, res);
      },
      eCallBack: function (res) {
        callBack && callBack(false, res);
      },
    }
    this.request(params);
  }
}

export { Order };
